// 防抖
function debounce (cb, delay) {
  let timer = null;
  return () => {
    if (timer) {
      clearTimeout(timer)
      timer = null
    }
    timer = setTimeout(() => {
      cb.apply(this, arguments)
    }, delay)
  }
}

// 节流
function throttle (cb, delay) {
  let timer = null;
  return () => {
    if (!timer) {
      timer = setTimeout(() => {
        cb.apply(this, arguments)
        clearTimeout(timer)
        timer = null
      }, delay)
    }
  }
}

const doSomeThing = () => {
  console.log("1111111111");
}

window.onscroll = debounce(doSomeThing, 1000)
window.onscroll = throttle(doSomeThing, 1000)


let unary = fn => val => fn(val)
let parse = unary(parseInt)
console.log(['1.1', '2', '0.3'].map(parse)) 

